{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name "0B02"
test("0B02 (move_file)", tests)
terminate_this_custom_script


const Test_Path_Src = "cleo\cleo_test_file.ini"
const Test_Path_Dst = "_test_file_B.ini"

function tests
    before_each(@cleanup)
    after_each(@cleanup)

    it("should fail on a non-existing file", test1)
    it("should move file", test2)
    return
    
    :cleanup
        delete_file {path} Test_Path_Src
        delete_file {path} Test_Path_Dst
    return
    
    function test1
        does_file_exist {dirPath} Test_Path_Src
        assert_result_false()
        
        move_file {path} Test_Path_Src {newPath} Test_Path_Dst // tested opcode
        assert_result_false()
    end
    
    function test2        
        // setup
        write_int_to_ini_file {value} 42 {path} Test_Path_Src {section} "test" {key} "test"
        assert_result_true()
        does_file_exist {dirPath} Test_Path_Src
        assert_result_true()
        does_file_exist {dirPath} Test_Path_Dst
        assert_result_false()
    
        // act
        move_file {path} Test_Path_Src {newPath} Test_Path_Dst // tested opcode
        assert_result_true()
        does_file_exist {dirPath} Test_Path_Src
        assert_result_false()
        does_file_exist {dirPath} Test_Path_Dst
        assert_result_true()
        
        int value = read_int_from_ini_file {path} Test_Path_Dst {section} "test" {key} "test"
        assert_eq(value, 42)
    end

end
